use djon::{ser::BinarySerializer, Value};
use serde::Serialize;

#[derive(Serialize)]
struct EntityProfile {
    health: i32,
    atk: i32,
    speed: i32,
}

#[derive(Serialize)]
struct Dummy {
    name: &'static str,
    data: EntityProfile,
}

fn main() {
    let mut buf = vec![];
    let mut ser = BinarySerializer::new(&mut buf);

    let dummy = Dummy {
        name: "A Nice Dummy",
        data: EntityProfile {
            health: 100,
            atk: 5,
            speed: 1,
        }
    };

    dummy.serialize(&mut ser).unwrap();

    let value = Value::read_bin(&mut buf.as_slice()).unwrap();

    println!("{value:?}");

    println!("{:?}", value.clone_child_recursive("data/health"))
}